<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>{$downData['title']}-附件下载</title>
  <style lang='scss'>
    .downFormBox {
      display: block;
      background: #fff;
      position: relative;
      max-width: 1600px;
      width: 80%;
      max-height: 80%;
      top: 10%;
      margin: 0 auto;
      padding: 50px;
      overflow-y: auto;
    }
    .downUrl {
      display: none;
    }
    .downFormBoxBg {
      display: none;
      width: 100%;
      height: 100%;
      position: fixed;
      top: 0;
      left: 0;
      background: rgba(0,0,0,.3);
      z-index: 9999;
    }
    .info {
      display: block;
      width: 100%;
      position: absolute;
      top: 10%;
      left: 0;
      line-height: 50px;
      color: #00bb00;
      text-align: center;
      z-index: 99999;
    }
    .downCloseIcon {
      display: block;
      width: auto;
      margin-top: 10px;
      padding: 0 30px;
      height: 30px;
      text-align: center;
      line-height: 30px;
      position: absolute;
      top: 10%;
      right: 10%;
      z-index: 99999;
      color: #f00f0f;
      border-radius: 30px;
      border: 1px solid #f00f0f;
      font-size: 14px;
      font-style: normal;
      cursor: pointer;
      transition: all .5s;-moz-transition: all .5s;-webkit-transition: all .5s; -o-transition: all .5s;
    }
    .downCloseIcon:hover {
      color: #fff;
      background: #f00f0f;
    }
  </style>
  <script src="__TMPL__/static/js/jquery.min.js"></script>
  <script src="/system_file/form/down.js"></script>
</head>
<body>
{$downFlag}
{if condition="$downFlag == true"}
<div class="downFormBtnBox">
  {volist name="$downData['fileArr']" id="vo" key="key"}
  <a class="downUrl" href="{$vo.url}" download="{$downData['title'] . '-附件' . $key}"></a>
  {/volist}
</div>
<script src="/system_file/form/down.js"></script>
<script>
  let boxObj = $('.downFormBtnBox');
  downArr = boxObj.find('.downUrl');
  for(i =0; i < downArr.length; i++) {
    fireClickEvent(downArr[i])
  }
  setTimeout(function () {
    window.close()
  }, 1000)
</script>
{else /}
<div class="downForm_{$downData['id']} downFormBtnBox" data-isForm="{$downData.is_form}">
  <div class="downFormBoxBg">
    <p class="info">请填写表单，填写表单后文件将会自动下载</p>
    {hcTaglib:form id="$downData['form_id']" class="downFormBox"/}
  </div>
</div>
<script>
  // Initialize the agent at application startup.
  // You can also use https://openfpcdn.io/fingerprintjs/v3/esm.min.js
  const fpPromise = import('/system_file/form/esm.min.js')
          .then(FingerprintJS => FingerprintJS.load())

  // Get the visitor identifier when you need it.
  fpPromise
          .then(fp => fp.get())
          .then(result => {
            console.log(result.visitorId)
            localStorage.setItem('visitorId', result.visitorId)
            let visitorId = '{$visitor_id}'
            if (!visitorId) {
              window.location.href = window.location.href + '?visitor_id=' + result.visitorId
            }
          })
</script>
<script>
  localStorage.setItem('sub_id', '{$downData["sub_id"]}')
  let visitorId = '{$visitor_id}'
  if (visitorId) {
    let boxObj = $('.downFormBtnBox');
    let is_form = boxObj.attr('data-isForm');
    if (is_form == '是') {
      boxObj.find('.downFormBoxBg').show()
    }
  }
</script>
{/if}
</body>
</html>
